<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   白话贝叶斯理论及在足球比赛结果预测中的应用和C#实现【附资料】  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/15882.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466459651: Accept with keywords: (title(0.222222222222):社区,预测,结果,白话,理论,数盟,足球比赛,资料,C#, topn(0.466666666667):初始化,社区,概率,账号,数盟,分类器,彩票,阶段,条件,类别,帐号,结果,特征,假设,模型,例子,计算,文章,数据,字典,预测,公式,问题,算法,训练样本,方法,分类,C#,比例,属性).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    白话贝叶斯理论及在足球比赛结果预测中的应用和C#实现【附资料】
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    白话贝叶斯理论及在足球比赛结果预测中的应用和C#实现【附资料】 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,78] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/15882.html">
          白话贝叶斯理论及在足球比赛结果预测中的应用和C#实现【附资料】
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          1,917 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech" rel="category tag">
          文章
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <div id="cnblogs_post_body">
        <p>
         <span data-wiz-span="data-wiz-span">
          离去年“
          <a href="http://www.cnblogs.com/asxinyu/p/3532076.html#3156396" target="_blank">
           马尔可夫链进行彩票预测
          </a>
          ”已经一年了，同时我也计划了一个彩票数据框架的搭建，分析和预测的框架，会在今年逐步发表，拟定了一个目录，大家有什么样的意见和和问题，可以看看，留言我会在后面的文章中逐步改善：
          <a href="http://www.cnblogs.com/asxinyu/p/4394169.html" target="_blank">
           彩票数据框架与分析预测总目录
          </a>
          。同时这篇文章也是“
          <a class="titlelink" href="http://www.cnblogs.com/asxinyu/p/3532076.html">
           【彩票】彩票预测算法(一)：离散型马尔可夫链模型C#实现
          </a>
          ”的兄弟篇。所以这篇文章还有一个标题，应该是：
          <a href="http://www.cnblogs.com/asxinyu/p/4394156.html" target="_blank">
           【彩票】彩票预测算法(二)：朴素贝叶斯分类器在足球胜平负预测中的应用及C#实现
          </a>
          。
         </span>
        </p>
        <p>
         <span data-wiz-span="data-wiz-span">
          以前了解比较多的是SVM，RF，特征选择和聚类分析，实际也做过一些分类预测的任务。在近1年多的时间中，开始接触足球赛事的预测，刚开始也想使用SVM，Rf来进行预测，一方面效果太差，二是其理论也的确不满足我自己想法的要求。所以也一直在看很多机器学习，数据挖掘的文章。直到看到了贝叶斯的相关文章，在这2个多月的研究中，也积累了很多经验，同时也在使用C#来完成自己的想法，在这个过程中，夹杂很多的知识要点，我自己也很乱，所以趁假期总结一下，由于写太多的公式大家也不一定能耐心看，也不易于理解，所以我把这篇文章叫做“大话贝叶斯”，目的就是尽量通过自己的简单语言和描述(当然如果确实需要学习贝叶斯来解决问题，有些基本概念，如条件概率，边缘分布，分布函数等等还是需要自己搞清楚)让大家更容易的懂得和理解贝叶斯相关理论及其应用。同时我通过实际的C#代码来进行演示，如何来用程序和贝叶斯理论来解决生活中的一些预测问题。
         </span>
         <span data-wiz-span="data-wiz-span">
          在接触所谓的贝叶斯理论和公式之前，先简单了解一下 贝叶斯。
         </span>
        </p>
        <p>
        </p>
        <h1 id="autoid-0-0-0">
         <span data-wiz-span="data-wiz-span">
          1.贝叶斯及其相关的理论
         </span>
        </h1>
        <h2 id="autoid-1-0-0">
         1.1 贝叶斯
        </h2>
        <div>
         <span data-wiz-span="data-wiz-span">
          贝叶斯是一名1702年出生于伦敦的英国数学家，他首先将归纳推理法用于概率论基础理论，并创立了贝叶斯统计
          <a href="http://baike.haosou.com/doc/5441427.html" target="_blank">
           理论
          </a>
          ，对于统计决策
          <a href="http://baike.haosou.com/doc/5368923.html" target="_blank">
           函数
          </a>
          、统计推断、统计的估算等做出了贡献，对于现代概率论和数理统计都有很重要的作用。所以看到的 贝叶斯 其实都是为了纪念这位伟大的数学家的贡献，贝叶斯公式也是他提出的，所以都是根据他的名字命名。
         </span>
        </div>
        <h2 id="autoid-1-1-0">
         <span data-wiz-span="data-wiz-span">
          1.2 贝叶斯方法的来源
         </span>
        </h2>
        <div>
         <span data-wiz-span="data-wiz-span">
          贝叶斯方法来源于贝叶斯本人在生前写过(死后朋友代为发表)的一篇关于“逆向概率”的文章，当时，人们已经可以根据实际的数据来计算“正向概率”。下面是一个“正向概率”的例子：
         </span>
        </div>
        <blockquote>
         <div>
          <div>
           <strong>
            <span data-wiz-span="data-wiz-span">
             “假设袋子里面有M个白色球，N个黑色球，如果伸手进去摸出一个球，那么摸出白色球的概率是多大？”。从这个问题，贝叶斯自然而然想到了“逆向概率”的问题：
            </span>
           </strong>
          </div>
          <div>
           <strong>
            <span data-wiz-span="data-wiz-span">
             “假设我们事先并不知道袋子里面黑白球的个数，而是先闭着眼睛摸出一个（或好几个）球，然后观察这些取出来的球的颜色之后，那么根据取出的球的信息，对袋子里面的黑白球的比例作出什么样的推测”。
            </span>
           </strong>
          </div>
         </div>
        </blockquote>
        <div>
         <span data-wiz-span="data-wiz-span">
         </span>
         这个问题，就是所谓的逆概问题。从我个人的理解就是如何根据有限的已知信息来推断未知情况的概率。
        </div>
        <div>
         <span data-wiz-span="data-wiz-span">
          贝叶斯的这篇论文虽然只是对这个问题的一个直接的求解尝试，并没有意识到这里面包含着的深刻的思想。由于复杂问题，贝叶斯推断需要大量的计算，因此在计算机未出现之前，并没有得到重视和广泛应用；计算机诞生以后，人们发现许多统计量是无法事先进行客观判断的，而互联网时代出现的大型数据集，再加上高速运算能力，为验证这些统计量提供了方便，也为应用贝叶斯推断创造了条件，它的威力正在日益显现[]。现在贝叶斯方法已经在各个领域得到大量的应用，也成为机器学习的核心算法之一。因为这个世界越来越复杂，影响事物发展的因素也越来越多，不确定性和随机性也不断增加，这个时候贝叶斯就发挥了他的优势。
         </span>
        </div>
        <h2 id="autoid-1-2-0">
         <span data-wiz-span="data-wiz-span">
          1.3 贝叶斯公式与定理
         </span>
        </h2>
        <div>
         <p>
          <span data-wiz-span="data-wiz-span">
           <a href="http://zh.wikipedia.org/wiki/%E8%B4%9D%E5%8F%B6%E6%96%AF%E5%AE%9A%E7%90%86">
            贝叶斯定理
           </a>
           是概率论中的一个结论，它跟随机变量的条件概率以及边缘概率分布有关。贝叶斯定理能够告知我们如何利用新证据修改已有的看法。作为一个普遍的原理，贝叶斯定理对于所有概率的解释是有效的；通常，事件A在事件B（发生）的条件下的概率，与事件B在事件A的条件下的概率是不一样的；然而，这两者是有确定的关系，贝叶斯定理就是这种关系的陈述。
          </span>
         </p>
         <p>
          设P(A|B)
          <span data-wiz-span="data-wiz-span">
           表示事件B已经发生的前提下，事件A发生的概率，叫做事件B发生下事件A的条件概率。下面就是贝叶斯公式：
          </span>
         </p>
         <p>
          <img src="http://dataunion.org/wp-content/uploads/2015/04/051459483102024.png"/>
         </p>
         <p>
          <span data-wiz-span="data-wiz-span">
           其中的符号定义为：
          </span>
         </p>
         <ul>
          <li>
           <span data-wiz-span="data-wiz-span">
            P(A)是事件A的先验概率或边缘概率，它不考虑任何B方面的因素。
           </span>
          </li>
          <li>
           <span data-wiz-span="data-wiz-span">
            P(A|B)是已知B发生后A的条件概率，也由于得自B的取值而被称作
            <strong>
             A的
            </strong>
            <strong>
             后验概率
            </strong>
            。
           </span>
          </li>
          <li>
           <span data-wiz-span="data-wiz-span">
            P(B|A)是已知A发生后B的条件概率，也由于得自A的取值而被称作
            <strong>
             B的
            </strong>
            <strong>
             后验概率
            </strong>
            。
           </span>
          </li>
          <li>
           <span data-wiz-span="data-wiz-span">
            P(B)是事件B的先验概率或边缘概率，也作
            <strong>
             标准化常量
            </strong>
            （
            <span lang="en" xml:lang="en">
             normalizing constant）。
            </span>
           </span>
          </li>
         </ul>
         <p>
          <span data-wiz-span="data-wiz-span">
           按这些术语，贝叶斯定理可表述为：
           <strong>
            后验概率 = (相似度*先验概率)/标准化常量
           </strong>
           。
          </span>
          <span data-wiz-span="data-wiz-span">
           简单的讲，贝叶斯定理是基于假设的先验概率，给定假设条件下，观察到不同数据的概率，提供一种计算后验概率的方法。
          </span>
         </p>
         <p>
          <span data-wiz-span="data-wiz-span">
           贝叶斯决策就是在不完全的信息下面，对部分未知的状态用主观概率来进行估计，然后用贝叶斯公式对发生概率进行修正，最后再利用期望值和修正概率做出最优决策。贝叶斯决策理论方法是统计模型决策中的一个基本方法，其基本思想是：
          </span>
          <span data-wiz-span="data-wiz-span">
           1、已知类条件概率密度参数表达式和先验概率。
          </span>
         </p>
         <p>
          <span data-wiz-span="data-wiz-span">
           2、利用贝叶斯公式转换成后验概率。
          </span>
         </p>
         <p>
          <span data-wiz-span="data-wiz-span">
           3、根据后验概率大小进行决策分类。
          </span>
         </p>
         <p>
          <span data-wiz-span="data-wiz-span">
           贝叶斯的这种基本思想可以在大量的实际案例中得到使用，因为很多现实社会中，积累了很多历史先验数据，想进行一些决策推理，也可以说是预测，就可以按照上面的步骤进行，当然贝叶斯理论的发展中，出现了很多新的推理算法，更加复杂，和面向不同的领域。一般来说，使用贝叶斯推理就是，预测某个事件下一次出现的概率，或者属于某些类别的概率，使用贝叶斯来进行分类的应用应该是最广泛的，很多实际的推理问题也可以转换为分类问题。下面将介绍一些贝叶斯理论的应用例子。
          </span>
         </p>
         <h2 id="autoid-1-3-0">
          1.4.贝叶斯的类型和应用
         </h2>
         <p>
          <span data-wiz-span="data-wiz-span">
           在人工智能领域，贝叶斯方法是一种非常有代表性的不确定性知识表示和推理方法。
          </span>
          目前贝叶斯的应用非常广泛，如文本分类，问题分类，反垃圾邮件等等，根据问题特征因素的独立性可以分为：朴素贝叶斯和贝叶斯网络。
         </p>
         <p>
          1.朴素贝叶斯的核心在于它假设向量的所有分量之间是独立的。（这一点在很多复杂的实际情况中都不太容易达到，各个因素直接可能都有一定的关联）;
         </p>
         <p>
          2.贝叶斯网络又叫概率因果网络或者知识图，是相对于朴素贝叶斯而言的。它是一种有方向的无环关系图；贝叶斯网络用图形来表示变量之间的连接个概率关系；它是为了解决不确定性问题和不完整性问题而提出的，在如文字处理，图像处理，决策支持等很多领域都得到广泛的应用。
         </p>
         <p>
          相关的学术研究进展，主要集中在贝叶斯网络的研究中：
         </p>
        </div>
        <div>
         <div>
          贝叶斯网络推理是指在给定证据条件下查询贝叶斯网络中某些节点的后验信息，其推理算法分为精确推理算法和近似推理算法两大类，至于这些算法的细节可以参考本后的文献
          <strong>
           “贝叶斯网络研究综述”，
          </strong>
          这玩意太复杂，一时半会我也没研究透彻，所以还是先搞懂下面几个简单的例子，对贝叶斯理论的应用有一个初步的认识比较好。
         </div>
         <h1 id="autoid-1-4-0">
          2.朴素贝叶斯分类及例子
         </h1>
         <div>
          <p>
           贝叶斯分类的基础是概率推理，就是在各种条件的存在不确定，仅知其出现概率的情况下，如何完成推理和决策任务。概率推理是与确定性推理相对应的。而朴素贝叶斯分类器是基于独立假设的，即假设样本每个特征与其他特征都不相关。举个例子，如果一种水果其具有红，圆，直径大概4英寸等特征，该水果可以被判定为是苹果。尽管这些特征相互依赖或者有些特征由其他特征决定，然而朴素贝叶斯分类器认为这些属性在判定该水果是否为苹果的概率分布上独立的。朴素贝叶斯分类器依靠精确的自然概率模型，在
           <strong>
            有监督学习
           </strong>
           的样本集中能获取得非常好的分类效果。在许多实际应用中，朴素贝叶斯模型参数估计使用
           <strong>
            最大似然估计
           </strong>
           方法，换而言之朴素贝叶斯模型能工作并没有用到
           <strong>
            贝叶斯概率
           </strong>
           或者任何贝叶斯模型。尽管是带着这些朴素思想和过于简单化的假设，但朴素贝叶斯分类器在很多复杂的现实情形中仍能够取得相当好的效果。我们先看看一个简单的例子，这里要特别感谢博客园网友：
           <a href="http://www.cnblogs.com/leoo2sk/" target="_blank">
            leoo2sk
           </a>
           ，因为这一节的内容和例子基本都来自他的这篇关于朴素贝叶斯分类器的简单介绍的文章：
           <a href="http://www.cnblogs.com/leoo2sk/archive/2010/09/17/naive-bayesian-classifier.html" target="_blank">
            文章链接
           </a>
           ，只不过我整理了一下，鉴于文章编辑不方便，我在word中编辑好了，截图上来：
          </p>
          <h2 id="autoid-2-0-0">
           2.1 朴素贝叶斯分类的定义
          </h2>
          <p>
           <img src="http://dataunion.org/wp-content/uploads/2015/04/051644052881986.png"/>
          </p>
          <p>
           <img src="http://dataunion.org/wp-content/uploads/2015/04/051648557109226.png"/>
          </p>
          <blockquote>
           <p>
            <strong>
             注意：上述的推导有2个地方比较难懂，1个是把分母p(x)去掉了，应该好理解，分母都一样，比较的时候，直接比较分子就可以了。另外一个是为什么这个公式是成立的：
            </strong>
           </p>
           <p>
            <strong>
             P(x|yi) = P(a1|yi)*P(a2|yi)*…*P(aj|yi)
            </strong>
           </p>
           <p>
            <strong>
             这个公式的成立是因为各个属性a1,a2,..,aj都是独立的，才能成立。
            </strong>
            <strong>
             <br/>
            </strong>
           </p>
          </blockquote>
          <p>
           根据上述原理，朴素贝叶斯分类主要分为三个阶段：
           <br/>
           <strong>
            1.准备阶段
           </strong>
           ，这个阶段的任务是为朴素贝叶斯分类做必要的准备，主要工作是根据具体情况确定特征属性，并对每个特征属性进行适当划分，然后由人工对一部分待分类项进行分类，形成训练样本集合。这一阶段的输入是所有待分类数据，输出是特征属性和训练样本。这一阶段是整个朴素贝叶斯分类中唯一需要人工完成的阶段，其质量对整个过程将有重要影响，分类器的质量很大程度上由特征属性、特征属性划分及训练样本质量决定。
           <br/>
           <strong>
            2.分类器训练阶段
           </strong>
           ，这个阶段的任务就是生成分类器，主要工作是计算每个类别在训练样本中的出现频率及每个特征属性划分对每个类别的条件概率估计，并将结果记录。输入是特征属性和训练样本，输出是分类器。这一阶段是机械性阶段，根据前面讨论的公式可以由程序自动计算。
           <br/>
           <strong>
            3.应用阶段
           </strong>
           。这个阶段的任务是使用分类器对待分类项进行分类，其输入是分类器和待分类项，输出是待分类项与类别的映射关系。这一阶段也是机械性阶段，由程序完成。
          </p>
          <p>
           至于贝叶斯的其他问题如 估计类别下特殊属性划分的条件概率，以及分类器的评价问题，我认为对于初学者可以暂时跳过，等把基本流程理顺了，懂了，越到更多的问题后再回过头来反思后，按需学习。
          </p>
          <h2 id="autoid-2-1-0">
           2.2 朴素贝叶斯分类实例:检测不真实账号
          </h2>
          <p>
           这个例子完全取自于博客园网友：
           <a href="http://www.cnblogs.com/leoo2sk/" target="_blank">
            leoo2sk
           </a>
           ，的文章“
           <a href="http://www.cnblogs.com/leoo2sk/archive/2010/09/17/naive-bayesian-classifier.html" target="_blank">
            算法杂货铺——分类算法之朴素贝叶斯分类
           </a>
           ”，因为这个例子很短，而且有现成数据，手动计算量很小，所以我认为非常适合在这里使用。所以冒昧借用一下，同时3.3节中，我会介绍一个更加复杂的朴素贝叶斯分类器的代码。这个例子适合入门，而且最好是动手拿笔在纸上画一画，这样更容易理解，光看公式和数据虽然简单，但未必能了解整个过程，要想自己写出类似的代码，这个过程还是要清楚的，至少我是这么过来的。看看SNS社区不真实帐号问题
          </p>
          <blockquote>
           <p>
            对于SNS社区来说，不真实账号（使用虚假身份或用户的小号）是一个普遍存在的问题，作为SNS社区的运营商，希望可以检测出这些不真实账号，从而在一些运营分析报告中避免这些账号的干扰，亦可以加强对SNS社区的了解与监管。如果通过纯人工检测，需要耗费大量的人力，效率也十分低下，如能引入自动检测机制，必将大大提升工作效率。这个问题说白了，就是要将社区中所有账号在真实账号和不真实账号两个类别上进行分类。
           </p>
          </blockquote>
          <p>
           下面我们一步一步的使用朴素贝叶斯实现这个过程。
          </p>
          <h3 id="autoid-2-2-0">
           2.2.1 准备阶段：特征属性及划分
          </h3>
          <p>
           1.首先设C=0表示真实账号，C=1表示不真实账号。其他例子中不一定只有2类，也可以是N个类别，只不过计算更复杂，要借助计算机和程序了。
          </p>
          <p>
           2.找出可以区分真实与不真实账号的特征属性，实际应用中，特征属性的数量可能很多，划分也会更细致。作为例子，这里只用少量的特征属性以及较粗的划分，并对数据做了修改。同时我们也假设这3个属性是独立的，这是使用朴素贝叶斯的基本要求。
          </p>
          <blockquote>
           <p>
            选择三个特征属性,在SNS社区中这三项是可以直接从数据库里得到的。粗略划分如下几个区间：
           </p>
           <p>
            a1：日志数量/注册天数，划分：{a1&lt;=0.05, 0.05&lt;a1&lt;0.2, a1&gt;=0.2}
           </p>
           <p>
            a2：好友数量/注册天数，划分：{a2&lt;=0.1, 0.1&lt;a2&lt;0.8, a2&gt;=0.8}
           </p>
           <p>
            a3：是否使用真实头像。 划分：{a3=0（不是）,a3=1（是）}
           </p>
          </blockquote>
          <h3 id="autoid-2-2-1">
           2.2.2 训练阶段：训练样本数据
          </h3>
          <blockquote>
           <p>
            这里并没有提供实际的数据，而是直接提供了相关整理后的数据，实际例子中，也应该是这样，这些基础数据是可以获取得到的。
           </p>
           <p>
            <strong>
             使用1万个人工检测过的账号作为训练样本。我们根据上面特征属性的划分计算每个类别的频率以及各个类别在各个条件下的条件概率，以供后面的预测需要。
            </strong>
           </p>
           <p>
            <strong>
             计算类别频率
            </strong>
           </p>
           <p>
            P(C=0) = 0.89; 也就说这1万个人工检测过的帐号中，有89%是真实的
           </p>
           <p>
            P(C=1) = 0.11;人工检测的帐号中，有11%是不真实的
           </p>
           <p>
            <strong>
             计算条件概率
            </strong>
           </p>
           <p>
            <strong>
             1）计算已知C=0的条件下，a1属性属于不同划分类别的条件概率
            </strong>
           </p>
           <p>
            P(      a1&lt;=0.05| C=0) = 0.3 ; 在帐号真实的情况下，日志数量/注册天数的值&lt;=0.05的比例有30%
           </p>
           <p>
            p(0.05&lt;a1&lt;0.2 | C=0) = 0.5 ;
           </p>
           <p>
            P(      a1 &gt;=0.2 | C=0) = 0.2 ;
           </p>
           <p>
            <strong>
             2）计算已知C=1的条件下，a1属性属于不同划分类别的条件概率
            </strong>
           </p>
           <p>
            P(      a1&lt;=0.05| C=1) = 0.8 ; 在帐号不真实的情况下，日志数量/注册天数的值&lt;=0.05的比例有80%
           </p>
           <p>
            p(0.05&lt;a1&lt;0.2 | C=1) = 0.1 ;
           </p>
           <p>
            P(      a1 &gt;=0.2 | C=1) = 0.1 ;
           </p>
           <p>
            <strong>
             3）计算已知C=0的条件下，a2属性属于不同划分类别的条件概率
            </strong>
           </p>
           <p>
            P(  a2 &lt;=  0.1  |  C=0) = 0.1 ;
           </p>
           <p>
            P(  0.1&lt;a2&lt;0.8|  C=0) = 0.7 ;在帐号真实条件下，好友数量/注册天数在0.1-0.8范围的比例是70%
           </p>
           <p>
            P(  a2 &gt;=  0.8  |  C=0) = 0.2 ;
           </p>
           <p>
            <strong>
             4）计算已知C=1的条件下，a2属性属于不同划分类别的条件概率
            </strong>
           </p>
           <p>
            P(  a2 &lt;=  0.1  |  C=1) = 0.7 ;不真实条件下的帐号，好友数量在这个范围是非常多的
           </p>
           <p>
            P(  0.1&lt;a2&lt;0.8|  C=1) = 0.2 ;
           </p>
           <p>
            P(  a2 &gt;=  0.8  |  C=1) = 0.1 ;
           </p>
           <p>
            <strong>
             5）计算已知C=0的条件下，a3属性属于不同划分类别的条件概率
            </strong>
           </p>
           <p>
            P(a3 = 0 | C=0) = 0.2 ;
           </p>
           <p>
            P(a3 = 1 | C=0) = 0.8 ;真实帐号中，使用真实图像的比例是80%
           </p>
           <p>
            <strong>
             6）计算已知C=1的条件下，a3属性属于不同划分类别的条件概率
            </strong>
           </p>
           <p>
            P(a3 = 0 | C=1) = 0.9 ;不真实帐号中，使用不真实图像的比例是90%
           </p>
           <p>
            P(a3 = 1 | C=1) = 0.1 ;
           </p>
          </blockquote>
          <p>
           上面这些数据从样本中可以直接统计得到。我也手动对几个条件概率进行了解释，我们假设还是比较符合真实情况的，虽然这个数据是原作者修正过的。
          </p>
          <h3 id="autoid-2-2-2">
           2.2.3 应用阶段：获取分类概率
          </h3>
          <p>
           根据上面贝叶斯公式得到的相关条件概率数据，那么如何来进行一个实际的预测分类。假设我们有一个如下的预测需求：
          </p>
          <blockquote>
           <p>
            某帐号使用
            <strong>
             非真实头像，日志数量与注册天数的比率为0.1
            </strong>
            ，
            <strong>
             好友数与注册天数的比率为0.2
            </strong>
            。这些数据是从该数据库直接获取的。
           </p>
           <p>
            <strong>
             那么这个人的账户是真实账户 还是 不真实账户呢？相应的概率又有多少呢？
            </strong>
           </p>
          </blockquote>
          <p>
           <strong>
            直接使用3.1节中的公式，我们计算在当前数据x发生的情况下，属于不同类别的概率，这里有2类，所以要计算一下2个东西：
           </strong>
          </p>
          <blockquote>
           <p>
            要计算 P(C=0|x)  和 P(C=1|x)的概率，然后比较大小，取最大值所在的类别就是我们分类的类别。当然我们不一定非要分类，而是可以将求出的概率提供给客户，作为一个参考值等等。而根据3.1节的推导，上述2个值的计算完整公式应该是下面这样的：
           </p>
           <p>
            <strong>
             P(C=0|x)
            </strong>
            = P(x|C=0)*P(C=0)
           </p>
           <p>
            = P(a1|C=0)*P(a2|C=0)*P(a3|C=0)*P(C=0) 根据x的属性范围选择对应的概率
           </p>
           <p>
            = P(0.05&lt;a1&lt;0.2|C=0) * P(0.1&lt;a2&lt;0.8|C=0)*P(a3=0|C=0) *P(C=0)
           </p>
           <p>
            = 0.5 * 0.7 * 0.2 * 0.89 = 0.0623
           </p>
           <p>
            同理：
           </p>
           <p>
            <strong>
             P(C=1|x)
            </strong>
            = P(0.05&lt;a1&lt;0.2|C=1) * P(0.1&lt;a2&lt;0.8|C=1)*P(a3=0|C=1) *P(C=1)
           </p>
           <p>
            = 0.1 * 0.2 * 0.9 * 0.11 = 0.00198
           </p>
           <p>
            所以根据属性结果和计算，当事件X发生时，属于C=0的概率要高得多，是C=1的30倍。因此我们有理由将这个帐号划分为真实帐号的范畴。
           </p>
          </blockquote>
          <p>
           当然实际中的情况可能更加复杂，计算量也更加大，朴素贝叶斯不一定能很好的完成复杂的任务。但有些时候，我们将文件简化为朴素贝叶斯也能收获一些意外的东西。下面我们就来看将贝叶斯分类应用到足球彩票胜平负结果的预测中的情况。纯C#代码。欢迎支持。
          </p>
          <h1 id="autoid-2-2-3">
           3.足球彩票的贝叶斯预测与C#实现
          </h1>
          <blockquote>
           <p>
            <strong>
             关于足球彩票预测的几点说明：
            </strong>
           </p>
           <p>
            1.本文分析的足球胜平负比赛的结果预测，采集的数据有近10年的全世界主要联赛；
           </p>
           <p>
            2.足球彩票的预测方法各种各样，八仙过海各显神通，我这里也只是初步的测试，还有很多工作待完成，有没有完善的地方大家也不要急。
           </p>
           <p>
            3.足球比赛的结果不仅与球队实力，状态，伤病，彩票，天气，还与场上的重大随机因素有关，因此想完成预测100%准确是一个不可能的任务，我们只是想在欧赔的概率基础上有少部分(5-10%)的提高，这样才可以做很多有意义的事情。
           </p>
           <p>
            4.准确的说，足球比赛的很多因素都是有关联的，我也只是处于好奇，先使用了朴素贝叶斯来进行了一些工作，同时也在着手开始研究贝叶斯网络的预测方法，比较复杂，还在学习与堆码中。
           </p>
           <p>
            5.1场足球比赛的基本要点有：主队，客队，比分，结果，至于辅助的因素有很多，如赛前的主客队积分，进球率，失球率，净胜球等等。
           </p>
           <p>
            6.本文使用的是数据库ORM组件XCode，相关数据查询及操作如果看不懂，可以参考本文博客的文章，点击菜单导航栏的：
            <a href="http://www.cnblogs.com/asxinyu/p/4329747.html" target="_blank">
             <strong>
              “X组件”
             </strong>
            </a>
            进入目录即可。
           </p>
          </blockquote>
          <p>
           我们还是按照前面的步骤来逐步构造一个贝叶斯分类器，在这个过程中，也会讲解相关细节，对于懂足球彩票的朋友，应该好懂，对于不懂，只是想了解的朋友，可以看看思路，了解初步过程，没必要了解细节。
          </p>
          <h2 id="autoid-3-0-3">
           3.1 选择属性与获取训练数据
          </h2>
          <p>
           为了简单起见，我暂时只选取2个属性：主客队总积分的差；主队主场积分与客队客场积分的差；结果有胜平负3种类别，分别记为(3,1,0)。属性集的划分我们在程序中动态获取，这样可以计算各种不同划分的准确率，更加方便，这和上面的例子是不一样的。当然上面的例子也可以这样做，只是一个小的技巧而已。
          </p>
          <p>
           在这个测试过程中，我们是选取前N轮的比赛场次数据，然后对后M轮的结果进行预测。所有首先要从数据库获取贝叶斯的训练数据，看代码：
          </p>
          <div class="cnblogs_code">
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686600ed132671923041" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              /// &amp;lt;summary&amp;gt;获取指定赛季，指定轮之间的比赛数据作为贝叶斯分类的训练集合&amp;lt;/summary&amp;gt;
/// &amp;lt;param name="seasonId"&amp;gt;赛季编号&amp;lt;/param&amp;gt;
/// &amp;lt;param name="roundIdL"&amp;gt;起始轮号&amp;lt;/param&amp;gt;
/// &amp;lt;param name="roundIdH"&amp;gt;截至轮号&amp;lt;/param&amp;gt;
/// &amp;lt;returns&amp;gt;返回贝叶斯需要的数据格式类型(自定义的)&amp;lt;/returns&amp;gt;
static List&amp;lt;BayesDS&amp;gt; GetDataBySeason(Int32 seasonId,Int32 roundIdL,Int32 roundIdH)
{
    var season = SeasonInfoDc.FindBySeasonId(seasonId);
    GameScreenDc.SetDbConnName(season.EventName);
    EventRanking.SetDbConnName(season.EventName);
    //获取所有场次
    var games = GameScreenDc.FindAll(GameScreenDc._.SeasonId == seasonId &amp;amp; 
                                       GameScreenDc._.RoundId &amp;gt;= roundIdL &amp;amp; 
                                       GameScreenDc._.RoundId &amp;lt;= roundIdH, 
                                       GameScreenDc._.RoundId.Asc(), null, 0, 0);
    //循环每场进行查找，组合
    List&amp;lt;BayesDS&amp;gt; res = new List&amp;lt;BayesDS&amp;gt;();

    foreach (var item in games)
    {
        //查找当前主客球队,上一轮后的积分对象
        var home = EventRanking.Find(EventRanking._.SeasonId == seasonId &amp;amp;
                                      EventRanking._.TeamId == item.HomeId &amp;amp;
                                      EventRanking._.RoundId == item.RoundId -1);
        var visit = EventRanking.Find(EventRanking._.SeasonId == seasonId &amp;amp;
                                        EventRanking._.TeamId == item.VisiteId &amp;amp; 
                                        EventRanking._.RoundId == item.RoundId -1);
        double[] temp = new double[]{(double)(home.TotalScore - visit.TotalScore)/*总积分差*/,
                   (double)(home.HomeScore - visit.VisitScore)/*主队主场积分-客队客场积分*/,
　　　　　　　　　　　　item.Result}; 
　　　　 res.Add(BayesDS.Create(item,temp));
   }
   return res;
}
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-8">
                   8
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-9">
                   9
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-10">
                   10
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-11">
                   11
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-12">
                   12
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-13">
                   13
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-14">
                   14
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-15">
                   15
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-16">
                   16
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-17">
                   17
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-18">
                   18
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-19">
                   19
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-20">
                   20
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-21">
                   21
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-22">
                   22
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-23">
                   23
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-24">
                   24
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-25">
                   25
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-26">
                   26
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-27">
                   27
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-28">
                   28
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-29">
                   29
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-30">
                   30
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-31">
                   31
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-32">
                   32
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed132671923041-33">
                   33
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed132671923041-34">
                   34
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-57686600ed132671923041-1">
                   <span class="crayon-c">
                    /// &amp;lt;summary&amp;gt;获取指定赛季，指定轮之间的比赛数据作为贝叶斯分类的训练集合&amp;lt;/summary&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-2">
                   <span class="crayon-c">
                    /// &amp;lt;param name="seasonId"&amp;gt;赛季编号&amp;lt;/param&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-3">
                   <span class="crayon-c">
                    /// &amp;lt;param name="roundIdL"&amp;gt;起始轮号&amp;lt;/param&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-4">
                   <span class="crayon-c">
                    /// &amp;lt;param name="roundIdH"&amp;gt;截至轮号&amp;lt;/param&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-5">
                   <span class="crayon-c">
                    /// &amp;lt;returns&amp;gt;返回贝叶斯需要的数据格式类型(自定义的)&amp;lt;/returns&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-6">
                   <span class="crayon-m">
                    static
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    BayesDS
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    GetDataBySeason
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-e">
                    Int32
                   </span>
                   <span class="crayon-v">
                    seasonId
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-e">
                    Int32
                   </span>
                   <span class="crayon-v">
                    roundIdL
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-e">
                    Int32
                   </span>
                   <span class="crayon-v">
                    roundIdH
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-7">
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-8">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    season
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    SeasonInfoDc
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    FindBySeasonId
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    seasonId
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-9">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    GameScreenDc
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    SetDbConnName
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    season
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    EventName
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-10">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    EventRanking
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    SetDbConnName
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    season
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    EventName
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-11">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //获取所有场次
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-12">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    games
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    GameScreenDc
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    FindAll
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    GameScreenDc
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    _
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    SeasonId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    ==
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    seasonId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    amp
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-13">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    GameScreenDc
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    _
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    RoundId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    roundIdL
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    amp
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-14">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    GameScreenDc
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    _
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    RoundId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    roundIdH
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-15">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    GameScreenDc
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    _
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    RoundId
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Asc
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    null
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-16">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //循环每场进行查找，组合
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-17">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    BayesDS
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    res
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    BayesDS
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-18">
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-19">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    foreach
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    item
                   </span>
                   <span class="crayon-st">
                    in
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    games
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-20">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-21">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //查找当前主客球队,上一轮后的积分对象
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-22">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    home
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    EventRanking
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Find
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    EventRanking
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    _
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    SeasonId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    ==
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    seasonId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    amp
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-23">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    EventRanking
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    _
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    TeamId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    ==
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    item
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    HomeId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    amp
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-24">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    EventRanking
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    _
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    RoundId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    ==
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    item
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    RoundId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-25">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    visit
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    EventRanking
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Find
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    EventRanking
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    _
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    SeasonId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    ==
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    seasonId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    amp
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-26">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    EventRanking
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    _
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    TeamId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    ==
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    item
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    VisiteId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    amp
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-27">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    EventRanking
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    _
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    RoundId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    ==
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    item
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    RoundId
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-28">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    temp
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    home
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    TotalScore
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    visit
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    TotalScore
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-c">
                    /*总积分差*/
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-29">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    home
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    HomeScore
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    visit
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    VisitScore
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-c">
                    /*主队主场积分-客队客场积分*/
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-30">
                   <span class="crayon-v">
                    item
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Result
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-31">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    res
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Add
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    BayesDS
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Create
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    item
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-v">
                    temp
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-32">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed132671923041-33">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    return
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    res
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed132671923041-34">
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0379 seconds] -->
          </div>
          <p>
           虽然只有2个参数，也需要进行划分，由于积分都是正整数，而且一般球队的积分差距不是特别大，为了测试不同划分的情况，我们选择手动输入划分点，进行属性的划分，下面是函数，根据输入的点，自动确定划分区间的：
          </p>
          <div class="cnblogs_code">
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686600ed147700642521" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              1 /// &amp;lt;summary&amp;gt;获取属性分割的区间，根据断点确定 ，data应该是从小到大的点排列&amp;lt;/summary&amp;gt;
 2 /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
 3 static double[][] GetRulesByPoint(List&amp;lt;double&amp;gt; data)
 4 {
 5     double[][] res = new double[data.Count +1][];
 6     res[0] = new double[] {-1000,data[0] };//下限-1000，不可能达到
 7     for (int i = 0; i &amp;lt; data.Count-1; i++)
 8     {
 9         res[i + 1] = new double[] { data[i], data[i +1] };
10     }
11     res[data.Count ] = new double[] {data[data.Count-1],1000 };//上限足够大，不可能达到
12     return res;
13 }
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-57686600ed147700642521-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed147700642521-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed147700642521-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed147700642521-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed147700642521-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed147700642521-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed147700642521-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed147700642521-8">
                   8
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed147700642521-9">
                   9
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed147700642521-10">
                   10
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed147700642521-11">
                   11
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed147700642521-12">
                   12
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed147700642521-13">
                   13
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-57686600ed147700642521-1">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    /// &amp;lt;summary&amp;gt;获取属性分割的区间，根据断点确定 ，data应该是从小到大的点排列&amp;lt;/summary&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed147700642521-2">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    2
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed147700642521-3">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    3
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-m">
                    static
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    GetRulesByPoint
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed147700642521-4">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    4
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed147700642521-5">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    5
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    res
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Count
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    +
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed147700642521-6">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    6
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    res
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-cn">
                    1000
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //下限-1000，不可能达到
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed147700642521-7">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    7
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    for
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Count
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-o">
                    ++
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed147700642521-8">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    8
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed147700642521-9">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    9
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    res
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    +
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    +
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed147700642521-10">
                   <span class="crayon-cn">
                    10
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed147700642521-11">
                   <span class="crayon-cn">
                    11
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    res
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-i">
                    Count
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Count
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-cn">
                    1000
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //上限足够大，不可能达到
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed147700642521-12">
                   <span class="crayon-cn">
                    12
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    return
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    res
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed147700642521-13">
                   <span class="crayon-cn">
                    13
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0165 seconds] -->
           <p>
           </p>
           <div class="cnblogs_code_toolbar">
           </div>
          </div>
          <h2 id="autoid-3-1-0">
           3.2 建立贝叶斯分类预测模型
          </h2>
          <p>
           有了数据和思路后，下一步就是要在C#中建立一个贝叶斯分类器，传递数据，和划分集然后才能进行预测。模型的定义如要有以下几点：
          </p>
          <p>
           <strong>
            1.几个基本的属性。
           </strong>
           注意字典存储条件概率，直接全部计算，对数据量大的情况，可能会吃不消，应该按需计算比较好。不过这里是测试，无所谓了。先看看效果才行。
          </p>
          <div class="cnblogs_code">
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686600ed151073172777" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              1 #region 属性
 2 /// &amp;lt;summary&amp;gt;测试数据：分别为属性值，最后1个为结果类别&amp;lt;/summary&amp;gt;
 3 public List&amp;lt;double[]&amp;gt; data { get; set; }
 4 /// &amp;lt;summary&amp;gt;对应的属性划分集合&amp;lt;/summary&amp;gt;
 5 public List&amp;lt;double[][]&amp;gt; rules { get; set; }
 6 /// &amp;lt;summary&amp;gt;所有的类别&amp;lt;/summary&amp;gt;
 7 public List&amp;lt;Int32&amp;gt; C { get; set; }
 8 /// &amp;lt;summary&amp;gt;类别的比例字典&amp;lt;/summary&amp;gt;
 9 public Dictionary&amp;lt;Int32,double&amp;gt; C_Ratio { get; set; }
10 /// &amp;lt;summary&amp;gt;条件概率字典&amp;lt;/summary&amp;gt;
11 public Dictionary&amp;lt;String, double&amp;gt; ConRatio { get; set; }
12 #endregion
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-57686600ed151073172777-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed151073172777-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed151073172777-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed151073172777-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed151073172777-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed151073172777-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed151073172777-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed151073172777-8">
                   8
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed151073172777-9">
                   9
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed151073172777-10">
                   10
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed151073172777-11">
                   11
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed151073172777-12">
                   12
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-57686600ed151073172777-1">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-p">
                    #region 属性
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed151073172777-2">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    2
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    /// &amp;lt;summary&amp;gt;测试数据：分别为属性值，最后1个为结果类别&amp;lt;/summary&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed151073172777-3">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    3
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-m">
                    public
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    data
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    get
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    set
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed151073172777-4">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    4
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    /// &amp;lt;summary&amp;gt;对应的属性划分集合&amp;lt;/summary&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed151073172777-5">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    5
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-m">
                    public
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    rules
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    get
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    set
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed151073172777-6">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    6
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    /// &amp;lt;summary&amp;gt;所有的类别&amp;lt;/summary&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed151073172777-7">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    7
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-m">
                    public
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    Int32
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    C
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    get
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    set
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed151073172777-8">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    8
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    /// &amp;lt;summary&amp;gt;类别的比例字典&amp;lt;/summary&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed151073172777-9">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    9
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-m">
                    public
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    Dictionary
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    Int32
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    C_Ratio
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    get
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    set
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed151073172777-10">
                   <span class="crayon-cn">
                    10
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    /// &amp;lt;summary&amp;gt;条件概率字典&amp;lt;/summary&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed151073172777-11">
                   <span class="crayon-cn">
                    11
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-m">
                    public
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    Dictionary
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    String
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    ConRatio
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    get
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    set
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed151073172777-12">
                   <span class="crayon-cn">
                    12
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-p">
                    #endregion
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0220 seconds] -->
          </div>
          <p>
           <strong>
            2.模型构造函数，主要是模型的初始化。
           </strong>
           这里我直接写好了，在初始化的时候就把数据和划分方式给模型，进行相关条件概率的计算，相关的注释已经在代码里面了，有几个注意的地方：条件概率在字典中的key是有格式的，后续也是根据这个来访问。
          </p>
          <div class="cnblogs_code">
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686600ed159914124100" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              1 #region 构造函数，初始化
 2 public BayesianClassifier(List&amp;lt;double[]&amp;gt; data, List&amp;lt;double[][]&amp;gt; rules, List&amp;lt;Int32&amp;gt; C)
 3 {
 4     this.data = data;
 5     this.rules = rules;
 6     this.C = C;
 7     Int32 N = data[0].Length - 1;//属性个数
 8     if (N != rules.Count) throw new Exception("属性划分集与属性个数对应错误");
 9     
10     //先计算样本中各类别的比例，保存在dic中
11     C_Ratio = C.ToDictionary(n =&amp;gt; n, n =&amp;gt; (double)data.Where(k =&amp;gt; n == k[N ]).Count() / (double)data.Count);
12 
13     //计算特征属性划分概率,存储在字典中
14     ConRatio = new Dictionary&amp;lt;String, double&amp;gt;();
15     for (int i = 0; i &amp;lt; C.Count; i++)//循环类别属性
16     {
17         var temp1 = data.Where(n =&amp;gt; n[N ] == C[i]);//当前类别的情况
18         //循环属性
19         for (int j = 0; j &amp;lt; N; j++)
20         {
21             //  循环该属性的所有划分集
22             for (int k = 0; k &amp;lt; rules[j].Length; k++)
23             {
24                 String key = String.Format("{0}{1}{2}", j,k,C[i] );//属性位置-划分位置-类别
25                 //计算当前的条件概率，判断data第j个属性，在等于C[k]的结果中，满足当前属性划分上下限的比例
26                 var temp2 = temp1.Where(n =&amp;gt; n[j].IsInRange(rules[j][k][0], rules[j][k][1]));
27                 double value = (double)temp2.Count() / (double)temp1.Count();
28                 ConRatio.Add(key, value);
29             }
30         }
31     }
32 }
33 #endregion
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-8">
                   8
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-9">
                   9
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-10">
                   10
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-11">
                   11
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-12">
                   12
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-13">
                   13
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-14">
                   14
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-15">
                   15
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-16">
                   16
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-17">
                   17
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-18">
                   18
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-19">
                   19
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-20">
                   20
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-21">
                   21
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-22">
                   22
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-23">
                   23
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-24">
                   24
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-25">
                   25
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-26">
                   26
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-27">
                   27
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-28">
                   28
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-29">
                   29
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-30">
                   30
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-31">
                   31
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed159914124100-32">
                   32
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed159914124100-33">
                   33
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-57686600ed159914124100-1">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-p">
                    #region 构造函数，初始化
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-2">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    2
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-m">
                    public
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    BayesianClassifier
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    Int32
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    C
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-3">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    3
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-4">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    4
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    this
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-5">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    5
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    this
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-6">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    6
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    this
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    C
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    C
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-7">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    7
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-i">
                    Int32
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    N
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Length
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //属性个数
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-8">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    8
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    if
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    N
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    !=
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Count
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    throw
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    Exception
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-s">
                    "属性划分集与属性个数对应错误"
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-9">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    9
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-10">
                   <span class="crayon-cn">
                    10
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //先计算样本中各类别的比例，保存在dic中
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-11">
                   <span class="crayon-cn">
                    11
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    C_Ratio
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    C
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    ToDictionary
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =&amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =&amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Where
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    k
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =&amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    ==
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    k
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-i">
                    N
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Count
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    /
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Count
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-12">
                   <span class="crayon-cn">
                    12
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-13">
                   <span class="crayon-cn">
                    13
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //计算特征属性划分概率,存储在字典中
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-14">
                   <span class="crayon-cn">
                    14
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    ConRatio
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    Dictionary
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    String
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-15">
                   <span class="crayon-cn">
                    15
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    for
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    C
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Count
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-o">
                    ++
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-c">
                    //循环类别属性
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-16">
                   <span class="crayon-cn">
                    16
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-17">
                   <span class="crayon-cn">
                    17
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    temp1
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Where
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =&amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-i">
                    N
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    ==
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    C
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //当前类别的情况
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-18">
                   <span class="crayon-cn">
                    18
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //循环属性
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-19">
                   <span class="crayon-cn">
                    19
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    for
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    N
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-o">
                    ++
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-20">
                   <span class="crayon-cn">
                    20
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-21">
                   <span class="crayon-cn">
                    21
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //  循环该属性的所有划分集
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-22">
                   <span class="crayon-cn">
                    22
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    for
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    k
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    k
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Length
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    k
                   </span>
                   <span class="crayon-o">
                    ++
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-23">
                   <span class="crayon-cn">
                    23
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-24">
                   <span class="crayon-cn">
                    24
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    String
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    key
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    String
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Format
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-s">
                    "{0}{1}{2}"
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-v">
                    k
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-v">
                    C
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //属性位置-划分位置-类别
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-25">
                   <span class="crayon-cn">
                    25
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //计算当前的条件概率，判断data第j个属性，在等于C[k]的结果中，满足当前属性划分上下限的比例
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-26">
                   <span class="crayon-cn">
                    26
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    temp2
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    temp1
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Where
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =&amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    IsInRange
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    k
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    k
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-27">
                   <span class="crayon-cn">
                    27
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    value
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-v">
                    temp2
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Count
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    /
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-v">
                    temp1
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Count
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-28">
                   <span class="crayon-cn">
                    28
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    ConRatio
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Add
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    key
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    value
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-29">
                   <span class="crayon-cn">
                    29
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-30">
                   <span class="crayon-cn">
                    30
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-31">
                   <span class="crayon-cn">
                    31
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed159914124100-32">
                   <span class="crayon-cn">
                    32
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed159914124100-33">
                   <span class="crayon-cn">
                    33
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-p">
                    #endregion
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0528 seconds] -->
          </div>
          <p>
           <strong>
            3.足球比赛场次胜平负结果的分类预测
           </strong>
          </p>
          <p>
           预测的过程也和第2节的例子一样，只不过是程序化了。预测的方法是每次一条记录的数据，并计算属于每一类的概率，所以返回的是一个字典，key为类别,value为概率。具体方法如下所示：
          </p>
          <div class="cnblogs_code">
           <div class="cnblogs_code_toolbar">
           </div>
           <p>
           </p>
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686600ed163399189185" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              1 /// &amp;lt;summary&amp;gt;分类：key为类别,value为概率&amp;lt;/summary&amp;gt;
 2 public Dictionary&amp;lt;Int32, double&amp;gt; ClassificationForDic(double[] data)
 3 {
 4     //先要计算每个当前属性的划分集合的顺序,找出每个属性所属于的区间
 5     List&amp;lt;Int32&amp;gt; attIdList = new List&amp;lt;int&amp;gt;();
 6     for (int i = 0; i &amp;lt; data.Length -1; i++)
 7     {
 8         for (int j = 0; j &amp;lt; rules[i].Length ; j++)
 9         {
10             if (data[i].IsInRange(rules[i][j][0], rules[i][j][1])) attIdList.Add(j);
11         }
12     }
13     
14     Dictionary&amp;lt;Int32, double&amp;gt; res = C_Ratio.ToDictionary(n=&amp;gt;n.Key,n =&amp;gt;
15         {
16             double multip = n.Value;
17             for (int i = 0; i &amp;lt; data.Length -1; i++)
18             {
19                 for (int j = 0; j &amp;lt; attIdList.Count; j++)
20                 {   //属性位置-划分位置-类别
21                     String key = String.Format("{0}{1}{2}",i,attIdList[j],n.Key);
22                     if (!ConRatio.ContainsKey(key)) multip = 0 ;
23                     else multip *= ConRatio[key];
24                 }
25             }
26             return multip;
27         });
28     return res;
29 }
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-8">
                   8
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-9">
                   9
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-10">
                   10
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-11">
                   11
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-12">
                   12
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-13">
                   13
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-14">
                   14
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-15">
                   15
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-16">
                   16
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-17">
                   17
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-18">
                   18
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-19">
                   19
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-20">
                   20
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-21">
                   21
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-22">
                   22
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-23">
                   23
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-24">
                   24
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-25">
                   25
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-26">
                   26
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-27">
                   27
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed163399189185-28">
                   28
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed163399189185-29">
                   29
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-57686600ed163399189185-1">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    /// &amp;lt;summary&amp;gt;分类：key为类别,value为概率&amp;lt;/summary&amp;gt;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-2">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    2
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-m">
                    public
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    Dictionary
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    Int32
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    ClassificationForDic
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-3">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    3
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-4">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    4
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //先要计算每个当前属性的划分集合的顺序,找出每个属性所属于的区间
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-5">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    5
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    Int32
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    attIdList
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-6">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    6
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    for
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Length
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-o">
                    ++
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-7">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    7
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-8">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    8
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    for
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-i">
                    Length
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-o">
                    ++
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-9">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    9
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-10">
                   <span class="crayon-cn">
                    10
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    if
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    IsInRange
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    attIdList
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Add
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-11">
                   <span class="crayon-cn">
                    11
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-12">
                   <span class="crayon-cn">
                    12
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-13">
                   <span class="crayon-cn">
                    13
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-14">
                   <span class="crayon-cn">
                    14
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    Dictionary
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    Int32
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    res
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    C_Ratio
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    ToDictionary
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-o">
                    =&amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Key
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =&amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-15">
                   <span class="crayon-cn">
                    15
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-16">
                   <span class="crayon-cn">
                    16
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    multip
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Value
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-17">
                   <span class="crayon-cn">
                    17
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    for
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    data
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Length
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-o">
                    ++
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-18">
                   <span class="crayon-cn">
                    18
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-19">
                   <span class="crayon-cn">
                    19
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    for
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    attIdList
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Count
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-o">
                    ++
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-20">
                   <span class="crayon-cn">
                    20
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //属性位置-划分位置-类别
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-21">
                   <span class="crayon-cn">
                    21
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    String
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    key
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    String
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Format
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-s">
                    "{0}{1}{2}"
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-v">
                    i
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-v">
                    attIdList
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    j
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Key
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-22">
                   <span class="crayon-cn">
                    22
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    if
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-o">
                    !
                   </span>
                   <span class="crayon-v">
                    ConRatio
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    ContainsKey
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    key
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    multip
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-23">
                   <span class="crayon-cn">
                    23
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    else
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e ">
                    multip *
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    ConRatio
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-v">
                    key
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-24">
                   <span class="crayon-cn">
                    24
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-25">
                   <span class="crayon-cn">
                    25
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-26">
                   <span class="crayon-cn">
                    26
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    return
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    multip
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-27">
                   <span class="crayon-cn">
                    27
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed163399189185-28">
                   <span class="crayon-cn">
                    28
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    return
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    res
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed163399189185-29">
                   <span class="crayon-cn">
                    29
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0428 seconds] -->
           <p>
           </p>
           <div class="cnblogs_code_toolbar">
           </div>
          </div>
          <p>
           返回这个字典后，要计算概率最大的结果也非常容易，直接对字典进行排序就可以了。具体代码看总的cs文件。
          </p>
          <h2 id="autoid-3-2-0">
           3.3 贝叶斯预测算法的测试
          </h2>
          <p>
           基本过程和代码完成了，我们采集5大联赛(西甲，德甲，英超，意甲，法甲)的数据进行测试，看看贝叶斯预测算法的准确性如何。测试的核心代码如下：
          </p>
          <div class="cnblogs_code">
           <div class="cnblogs_code_toolbar">
           </div>
           <p>
           </p>
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686600ed16c484532126" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              1 public static void TestBySeason()
 2 {
 3     //五大联赛的赛季编号
 4     List&amp;lt;Int32&amp;gt; seasonList = new List&amp;lt;int&amp;gt;() {6000,4866 };//4865,16136,4863,4861,5994  
 5     //先初始化联赛排名
 6     seasonList.ForEach(n =&amp;gt; EventRanking.UpdateHisSeason(n));
 7     int trainRoundL = 8;int trainRoundH = 25;//训练集的起至轮数
 8     int testRoundL = 26; int testRoundH = 35;//测试集的起至轮数
 9     List&amp;lt;double[]&amp;gt; trainData = new List&amp;lt;double[]&amp;gt;();//训练集
10     foreach (var item in seasonList)
11     {
12         var temp = GetDataBySeason(item,trainRoundL,trainRoundH).Select(n=&amp;gt;n.Data).ToList();
13         trainData.AddRange(temp);
14     }  
15     //然后采集测试集的数据，标签用于对比，测试时是不用的，只是最后对比使用
16     List&amp;lt;BayesDS&amp;gt; testData = new List&amp;lt;BayesDS&amp;gt;();//训练集
17     foreach (var item in seasonList)
18     {
19         var temp = GetDataBySeason(item, testRoundL, testRoundH);
20         testData.AddRange(temp);
21     }    
22     while (true)//循环根据不同属性划分进行测试
23     {
24         Console.Write("总积分差 属性分割集(参考：-8, -2, +5, 10)：");
25         var t1 = Console.ReadLine().StringToDoubleArray().ToList();
26         Console.Write("主客积分差 属性分割集(参考：-5, -1, +5)：");
27         var t2 = Console.ReadLine().StringToDoubleArray().ToList();
28         List&amp;lt;double[][]&amp;gt; rules = new List&amp;lt;double[][]&amp;gt;();
29         rules.Add(GetRulesByPoint(t1));//总积分差   参考：{ -8, -2, +5, 10 })
30         rules.Add(GetRulesByPoint(t2));//主客积分差 参考：{ -5, -1, +5 })
31         //初始化模型
32         BayesianClassifier bayesMode = new BayesianClassifier(trainData, rules, new List&amp;lt;int&amp;gt;() { 3, 1, 0 });    
33         var testResuult = testData.Select(n =&amp;gt;
34             {
35                 var res = bayesMode.Classification(n.Data);//预测结果
36             }).ToList();        
37     }
38 }
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-8">
                   8
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-9">
                   9
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-10">
                   10
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-11">
                   11
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-12">
                   12
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-13">
                   13
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-14">
                   14
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-15">
                   15
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-16">
                   16
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-17">
                   17
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-18">
                   18
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-19">
                   19
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-20">
                   20
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-21">
                   21
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-22">
                   22
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-23">
                   23
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-24">
                   24
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-25">
                   25
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-26">
                   26
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-27">
                   27
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-28">
                   28
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-29">
                   29
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-30">
                   30
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-31">
                   31
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-32">
                   32
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-33">
                   33
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-34">
                   34
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-35">
                   35
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-36">
                   36
                  </div>
                  <div class="crayon-num" data-line="crayon-57686600ed16c484532126-37">
                   37
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-57686600ed16c484532126-38">
                   38
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-1">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-m">
                    public
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-m">
                    static
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    void
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    TestBySeason
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-2">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    2
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-3">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    3
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //五大联赛的赛季编号
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-4">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    4
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    Int32
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    seasonList
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                   <span class="crayon-cn">
                    6000
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-cn">
                    4866
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //4865,16136,4863,4861,5994
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-5">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    5
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //先初始化联赛排名
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-6">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    6
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    seasonList
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-st">
                    ForEach
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =&amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    EventRanking
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    UpdateHisSeason
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-7">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    7
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    trainRoundL
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    8
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    trainRoundH
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    25
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //训练集的起至轮数
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-8">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    8
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    testRoundL
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    26
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    testRoundH
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    35
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //测试集的起至轮数
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-9">
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    9
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    trainData
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //训练集
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-10">
                   <span class="crayon-cn">
                    10
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    foreach
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    item
                   </span>
                   <span class="crayon-st">
                    in
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    seasonList
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-11">
                   <span class="crayon-cn">
                    11
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-12">
                   <span class="crayon-cn">
                    12
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    temp
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    GetDataBySeason
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    item
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-v">
                    trainRoundL
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-v">
                    trainRoundH
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Select
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-o">
                    =&amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Data
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    ToList
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-13">
                   <span class="crayon-cn">
                    13
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    trainData
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    AddRange
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    temp
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-14">
                   <span class="crayon-cn">
                    14
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-15">
                   <span class="crayon-cn">
                    15
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //然后采集测试集的数据，标签用于对比，测试时是不用的，只是最后对比使用
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-16">
                   <span class="crayon-cn">
                    16
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    BayesDS
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    testData
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-v">
                    BayesDS
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //训练集
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-17">
                   <span class="crayon-cn">
                    17
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    foreach
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    item
                   </span>
                   <span class="crayon-st">
                    in
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    seasonList
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-18">
                   <span class="crayon-cn">
                    18
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-19">
                   <span class="crayon-cn">
                    19
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    temp
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    GetDataBySeason
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    item
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    testRoundL
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    testRoundH
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-20">
                   <span class="crayon-cn">
                    20
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    testData
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    AddRange
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    temp
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-21">
                   <span class="crayon-cn">
                    21
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-22">
                   <span class="crayon-cn">
                    22
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-st">
                    while
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-t">
                    true
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-c">
                    //循环根据不同属性划分进行测试
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-23">
                   <span class="crayon-cn">
                    23
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-24">
                   <span class="crayon-cn">
                    24
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    Console
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Write
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-s">
                    "总积分差 属性分割集(参考：-8, -2, +5, 10)："
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-25">
                   <span class="crayon-cn">
                    25
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    t1
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    Console
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    ReadLine
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    StringToDoubleArray
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    ToList
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-26">
                   <span class="crayon-cn">
                    26
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    Console
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Write
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-s">
                    "主客积分差 属性分割集(参考：-5, -1, +5)："
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-27">
                   <span class="crayon-cn">
                    27
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    t2
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    Console
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    ReadLine
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    StringToDoubleArray
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    ToList
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-28">
                   <span class="crayon-cn">
                    28
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    double
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-sy">
                    [
                   </span>
                   <span class="crayon-sy">
                    ]
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-29">
                   <span class="crayon-cn">
                    29
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Add
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-e">
                    GetRulesByPoint
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    t1
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //总积分差   参考：{ -8, -2, +5, 10 })
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-30">
                   <span class="crayon-cn">
                    30
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Add
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-e">
                    GetRulesByPoint
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    t2
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //主客积分差 参考：{ -5, -1, +5 })
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-31">
                   <span class="crayon-cn">
                    31
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-c">
                    //初始化模型
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-32">
                   <span class="crayon-cn">
                    32
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    BayesianClassifier
                   </span>
                   <span class="crayon-v">
                    bayesMode
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    BayesianClassifier
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    trainData
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    rules
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-r">
                    new
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    List
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-t">
                    int
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    3
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    1
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    0
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-33">
                   <span class="crayon-cn">
                    33
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    testResuult
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    testData
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Select
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =&amp;
                   </span>
                   <span class="crayon-v">
                    gt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-34">
                   <span class="crayon-cn">
                    34
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    {
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-35">
                   <span class="crayon-cn">
                    35
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-t">
                    var
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    res
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    bayesMode
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    Classification
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    n
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-v">
                    Data
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-c">
                    //预测结果
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-36">
                   <span class="crayon-cn">
                    36
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    ToList
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-57686600ed16c484532126-37">
                   <span class="crayon-cn">
                    37
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-57686600ed16c484532126-38">
                   <span class="crayon-cn">
                    38
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-sy">
                    }
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0621 seconds] -->
           <p>
           </p>
           <div class="cnblogs_code_toolbar">
           </div>
          </div>
          <p>
           <strong>
            1.数据集采用2013-2014赛季，欧洲5大联赛的比赛，
           </strong>
           我们选取前8-25轮的场次作为训练集，26-35轮的比赛作为测试集合(考虑到联赛初期和末期的不稳定性)。
          </p>
          <p>
           <img src="http://dataunion.org/wp-content/uploads/2015/04/171406083851997.jpg"/>
          </p>
          <p>
           我们可以看到，针对不同的划分集，指数1的准确率都超过了57%，比正常的欧赔指数45-50%，高出了5-10%。结果还是比较可观的。但是我们也看到指数3的比例都有22%，说明对于一些特别冷门的场次，算法还是做不到，这些特殊情况不是简单2个因素就可以左右的，因此还有待对模型更深一步的研究，找出这些特别冷门场次的一些共同因素，从而进行一定程度的防范，减少指数3的比例，从而提高指数1，2的比例。
          </p>
          <p>
           <strong>
            2.同时，我们对上一步的测试方法进行了一定的更改
           </strong>
           ，将预测结果和欧赔bet 365指数1结果一致的比赛拿出来进行统计；将预测结果和欧赔bet 365指数1，2结果一致的比赛进行统计：
          </p>
          <p>
           同样是上述481场比赛进行筛选和属性划分，我们对实际的准确率进行比较：
          </p>
          <p>
           <img src="http://dataunion.org/wp-content/uploads/2015/04/171422184797961.jpg"/>
          </p>
          <p>
           通过结合欧赔指数，进行一定的过滤后，预测的整理准确率有了一定的提高。这个结果还是很理想的，懂的人应该知道里面的含义。所以贝叶斯理论的确是非常强大，当然这里只采用了2个因素，而且本身是关联的，但实际中没有考虑关联性，看成了朴素贝叶斯，必定会对问题结果产生一定的影响。这和我解决问题的思路有关系，先简单，后复杂，逐步过渡，延伸。。
          </p>
          <h1 id="autoid-3-3-0">
           4.参考文献与资料
          </h1>
          <p>
           博客园很多网友多对伪原创网站抓取文章做出过防范对策，我也发现这个问题，所以也想出了2个办法。
          </p>
          <p>
           1.在博客正文加上本文的链接，当然部分网站会无良的把所有链接给去掉，但可以防范部分，另外水印这些也有点用，只是比较麻烦，懒得搞
          </p>
          <p>
           2.也是我的必杀技，资料不直接开放下载，而是在文章发表后的12-24小时后再把链接发出来，或者通过邮箱发送。因为网站抓取一般都是对首页文章进行抓取，在发表12-24小时后，在进行抓取的频率就少多了。
           <strong>
            鉴于此，本文的资源将在发表后的24小时公开百度网盘的下载链接，所以大家可以关注博客，或者留下邮箱，在24小时后，统一邮箱发送。打包的资料文章有：
           </strong>
          </p>
          <div>
           贝叶斯分类方法及其在冠心病诊疗中的应用研究.
          </div>
          <div>
           贝叶斯网络研究
          </div>
          <div>
           基于WEKA平台的贝叶斯分类器的扩展
          </div>
          <div>
           基于贝叶斯方法的分类问题研究
          </div>
          <div>
           基于粗糙集的加权朴素贝叶斯分类算法研究
          </div>
          <div>
           基于粗糙集的朴素贝叶斯分类算法研究
          </div>
          <div>
           基于改进的K-均值算法的朴素贝叶斯分类及应用
          </div>
          <div>
           基于聚类的朴素贝叶斯分类模型的研究与应用
          </div>
          <div>
           加权贝叶斯增量学习中文文本分类研究
          </div>
          <div>
           面向不确定性数据的贝叶斯分类方法研究
          </div>
          <p>
           <strong>
            上述论文由于涉及到版权，已经取消下载取消下载，如需要请留言或者邮件索取。
           </strong>
          </p>
          <p>
           <strong>
            请到原始网页
           </strong>
           ：
           <a href="http://www.cnblogs.com/asxinyu/p/4394156.html" id="Editor_Edit_hlEntryLink" target="_blank" title="view: 白话贝叶斯理论与贝叶斯足球彩票预测算法的C#实现【附资料】">
            http://www.cnblogs.com/asxinyu/p/4394156.html
           </a>
           进行下载。
          </p>
          <div>
           <strong>
            参考的相关网页：
           </strong>
          </div>
          <div>
           <p>
            1.
            <a href="http://mindhacks.cn/2008/09/21/the-magical-bayesian-method/" target="_blank">
             数学之美番外篇：平凡而又神奇的贝叶斯方法
            </a>
           </p>
           <p>
            <span data-wiz-span="data-wiz-span">
             2.
             <a href="http://baike.baidu.com/link?url=-R6fYSDc2c1ysVDacWvl_EUuj8q9Zdr0ebIEWBT8LOaVT-XfHjCYha1j4kHrDc3awQ8We07qbphdrATdFQhAAq" target="_blank">
              百度百科-贝叶斯
             </a>
             <br/>
            </span>
           </p>
           <p>
            <span data-wiz-span="data-wiz-span">
             3.
             <a href="http://zh.wikipedia.org/wiki/%E8%B4%9D%E5%8F%B6%E6%96%AF%E5%AE%9A%E7%90%86" target="_blank">
              贝叶斯定理
             </a>
            </span>
           </p>
           <p>
            <span data-wiz-span="data-wiz-span">
             4.
             <a href="http://www.cnblogs.com/leoo2sk/archive/2010/09/17/naive-bayesian-classifier.html" target="_blank">
              算法杂货铺——分类算法之朴素贝叶斯分类
             </a>
            </span>
           </p>
           <p>
           </p>
          </div>
         </div>
        </div>
       </div>
       <div id="MySignature">
        <p>
         <span style="color: #0000ff;">
          作者：.NET技术爱好者，彩票分析预测
         </span>
        </p>
        <p>
         <a href="http://www.cnblogs.com/asxinyu/">
          <span style="color: #0000ff;">
           本文原始作者博客http://www.cnblogs.com/asxinyu
          </span>
         </a>
        </p>
        <p>
         <span style="color: #0000ff;">
          E-mail:1287263703@qq.com
         </span>
        </p>
       </div>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/12344.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/03/u25243708072335125207fm21gp0-300x194.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/12344.html" rel="bookmark" title="朴素贝叶斯分类器本质上是线性分类器">
         朴素贝叶斯分类器本质上是线性分类器
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/11650.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/03/292-1101020U22758_副本.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/11650.html" rel="bookmark" title="贝叶斯的路——概率论迷思">
         贝叶斯的路——概率论迷思
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/9502.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/i1-thumb_副本.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/9502.html" rel="bookmark" title="数学之美番外篇：平凡而又神奇的贝叶斯方法">
         数学之美番外篇：平凡而又神奇的贝叶斯方法
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24220.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/05/100910rrxp5plglxk4lcle-291x200.png"/>
        </a>
        <a class="link" href="http://dataunion.org/24220.html" rel="bookmark" title="520大数据：八成男性期待被表白 “套路”也是爱">
         520大数据：八成男性期待被表白 “套路”也是爱
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F15882.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/15882.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/15882.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>